from django.db import models

# Create your models here.


class SiteGroup(models.Model):
    name = models.CharField(max_length=32)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = '网址分组'
        verbose_name_plural = verbose_name


class WebSite(models.Model):

    title = models.CharField(verbose_name='标题',max_length=64)
    path = models.CharField(max_length=1024)
    title = models.CharField(max_length=32)
    icon = models.ImageField(upload_to='icon/%Y/%m', default='icon/default.jpeg', blank=True, verbose_name='icon')
    gmt_create = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    gmt_modified = models.DateTimeField(auto_now=True, verbose_name="编辑时间")
    desc =  models.CharField(max_length=50, blank=True, null=True, verbose_name="描述")
    group = models.ForeignKey(SiteGroup, on_delete=models.CASCADE, related_name='websites')

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = '网址'
        verbose_name_plural = verbose_name